package main

import (
	"books/models"

	"github.com/wailsapp/wails/v2/pkg/runtime"
)

func (a *App) GetUsers(name string, email string) []models.User {
	users, err := models.GetUsers(name, email)
	if err != nil {
		runtime.EventsEmit(a.ctx, "error", err.Error())

		return nil
	}

	return users
}

func (a *App) CreateUser(name, email, password string) error {
	user := models.User{
		Name:     name,
		Email:    email,
		Password: password,
	}

	return user.CreateUser()
}
